﻿/*
 * Copyright © 2020, Wuxi Safover Intelligent Technology Co., Ltd. All rights reserved.
 * 
 * 无锡安永智能科技有限公司版权所有，未经许可，不得用于商业用途
 * 
 * Visit: https://www.safover.com/ 
 */

using SafoverWpfFw;
using System.Windows.Input;
using Safover.LidarCollector.Models;
using Safover.LidarCollector.Config;

namespace Safover.LidarCollector.ViewModel
{
    public class RotaryTableConfigViewModel : BaseViewModel
    {
        public ICommand SaveCommand { get; set; }

        public string PortName { get; set; }

        public ushort BaudRate { get; set; }

        public RotaryTableConfigViewModel(RotaryTableConfig config)
        {
            PortName = config.PortName;
            BaudRate = config.BaudRate;

            SaveCommand = new RelayCommand(Save);
        }

        private void Save()
        {
            var config = new RotaryTableConfig
            {
                PortName = PortName,
                BaudRate = BaudRate,
            };

            RuntimeConfigManager.Instance.Save(config);

            _ = DI.UI.ShowMessage(new MessageBoxDialogViewModel
            {
                Title = "提示",
                Message = "保存成功！"
            });
        }
    }
}
